#pragma once
#include <vector>
#include "dataTypes.h"
#include "Color.h"
using namespace std;

class Particle
{
	public:
		Particle(int aLife, ALLEGRO_COLOR aColor, Point aPosition, float aSpeed, float aDirection)
		{
			life = aLife;
			time = 1;
			al_unmap_rgb(aColor,&r,&g,&b);
			a = 255;
			position = aPosition;

			speed.x = aSpeed*cos(aDirection);
			speed.y = aSpeed*sin(aDirection);
		}

		int life;
		int time;
		unsigned char r,g,b,a;
		Point position;
		Point speed;
};

class ParticleSystem
{
	public:
		ParticleSystem(EParticleEffect aEffect, Node aSource);
		~ParticleSystem();

		Node GetSource() {return source;};
		vector<Particle>* GetParticles() {return &particles;};
		void Tick();

	private:
		vector<Particle> particles;
		EParticleEffect actualEffect;
		Node source;
		Color color;

		unsigned int maxParticles;
		float direction;
		float disorder;
		float minSpeed, maxSpeed;

		void AddParticle(bool aStarting = false);
};

